package org.example.curriculum_design_6_16.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry corsRegistry) {
        corsRegistry.addMapping("/**")
                .allowedOrigins(
                        "http://localhost:8081",
                        "http://127.0.0.1:8081",
                        "http://8.130.133.165:8801",
                        "https://8.130.133.165:8801",
                        "http://8.130.133.165:9000",
                        "https://8.130.133.165:9000",
                        "http://8.130.133.165:8800",
                        "https://8.130.133.165:8800"
                )
                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH")
                .allowedHeaders("Authorization", "Content-Type", "X-Requested-With", "Accept", "Origin", "X-XSRF-TOKEN")
                .allowCredentials(true)
                .maxAge(3600);
    }
}
